package com.bailong.administrator.ausedcar.ui.detail;

import android.os.Bundle;
import android.support.v4.view.ViewPager;
import android.support.v7.app.AppCompatActivity;
import android.util.Log;
import android.widget.TextView;

import com.bailong.administrator.ausedcar.R;
import com.bailong.administrator.ausedcar.bean.DetailBean;

import java.util.ArrayList;
import java.util.List;

import butterknife.Bind;
import butterknife.ButterKnife;

public class DetailActivity extends AppCompatActivity implements DetailContract.View {

    @Bind(R.id.detail_tv_head)
    TextView detailTvHead;
    @Bind(R.id.detail_viewpager)
    ViewPager detailviewpager;
    @Bind(R.id.detail_tv_title)
    TextView detailTvTitle;
    @Bind(R.id.detail_tv_pay)
    TextView detailTvPay;
    @Bind(R.id.detail_tv_price)
    TextView detailTvPrice;
    @Bind(R.id.detail_tv_time)
    TextView detailTvTime;
    @Bind(R.id.detail_tv_num)
    TextView detailTvNum;
    @Bind(R.id.detail_tv_xingzhi)
    TextView detailTvXingzhi;
    @Bind(R.id.detail_tv_address)
    TextView detailTvAddress;
    private List<DetailBean.DataBean.PicListBean> totallist =new ArrayList<>();
    private DetailAdapter detailAdapter;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_detail);
        ButterKnife.bind(this);
        String carid = getIntent().getStringExtra("carid");

        DetailPresenter detailPresenter = new DetailPresenter(this);
        detailPresenter.loadDetailBean();

    }

    @Override
    public void onResponse(DetailBean bean) {

        detailTvHead.setText(bean.getData().getCarserie());
        detailTvTitle.setText(bean.getData().getCarname_full());
        detailTvPrice.setText("当时购入价格"+bean.getData().getPrice_new()+"(含税)");
        detailTvTime.setText(bean.getData().getPublish_time());
        detailTvNum.setText(bean.getData().getStatus());
        detailTvXingzhi.setText(bean.getData().getCartype_show());
        detailTvAddress.setText(bean.getData().getCityname());
        detailAdapter=new DetailAdapter(this,totallist);
        detailviewpager.setAdapter(detailAdapter);
        detailAdapter.reloadData(bean.getData().getPic_list());
    }
}
